package com.cskaoyan.mall.commons.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;

/**
 * @author LY
 * @since 2022/06/18 14:17
 */

public class HeaderUtil {

    public static Long getUserId(HttpServletRequest request) {
        // 从请求头获取userId
        String userInfo = request.getHeader("user_info");
        JSONObject jsonObject = JSON.parseObject(userInfo);
        return Long.parseLong(jsonObject.get("uid").toString());
    }
}
